import { toRaw } from 'vue'
import { defineStore } from 'pinia'
// 第一个参数是应用程序中 store 的唯一 id
export const routesList = defineStore('routesList', {
  state: () => ({
    routesList: [
      {
        name: '首页',
        url: '/home'
      },
      {
        name: '创新积分',
        url: '/InnovationPoints'
      }
    ],
    routerName: '/home',
    labels: <any[]>[]
  }),
  getters: {
    // 过滤列表中自动补全的数据
    setlabels(state) {
      return state.routesList.filter((item) => item.url == toRaw(state.routerName))
    }
  },
  actions: {
    // 设置路由集合
    async setRouterList(data: any) {
      this.routesList = data
    }
  }
})
